var version = 1.0
booking = ['a7.jpg', 'a7.jpg', 'a8.jpg', 'a9.jpg']

index = 0

function showImg() {
    //1.获取div标签对象
    var loop = document.getElementsByClassName('loop')[0]
    //2.设置div的背景图片样式
    loop.style.backgroundImage = `url(../booking/${booking[index]})`
    if (index < 3)
        index++
    else
        index = 0
}

window.setInterval(function () {
    showImg()
}, 3000)



window.onload = function () {
    var lis = document.getElementsByTagName('li')
    for (let i = 0; i < lis.length; i++) {
        lis[i].onclick = function () {
            index = i
            showImg()
        }
    }

    var Prev = document.getElementsByClassName('prev')[0]
    var next = document.getElementsByClassName('next')[0]
    Prev.onclick = function () {
        if (index > 0)
            index--
        showImg()
    }

 next.onclick = function () {
    if (index < 3)
       index++
    showImg()
 }
}
document.getElementById('scrollToSection2').addEventListener('click', function(event) {
    event.preventDefault(); 
    document.getElementById('section2').scrollIntoView({ behavior: 'smooth' });
});
    